<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/**
 * 通用化API接口数据输出
 * @param int $status 业务状态码
 * @param string $message 信息提示
 * @param [] $data  数据
 * @param int $httpCode http状态码
 * @return array
 */
function VV($success = true, $message='', $data=[],$status = 0) {
    $data = [
        "success"=> $success,
        'message' => $message,
        'data' => $data,
        'status' => $status,
    ];
    return $data;
}

/**
 * 数据签名认证
 * @param  array $post_data 被认证的数据
 * @return string       签名
 */
function user_sign($post_data){
    //数据类型检测
    if (!is_array($post_data)) {
        $post_data = (array)$post_data;
    }
    ksort($post_data); //排序
    $code = http_build_query($post_data); //url编码并生成query字符串
    $sign = sha1($code); //生成签名
    return $sign;
}

